# Maintainer: Christian Rebischke <chris.rebischke@archlinux.org>
pkgname=datree
pkgver=1.8.8
pkgrel=1
pkgdesc="CLI tool to ensure K8s manifests and Helm charts follow best practices as well as your organization’s policies"
arch=('loong64' 'x86_64')
url='https://github.com/datreeio/datree'
license=('Apache')
depends=('kubectl')
makedepends=('git' 'go')
source=("${pgname}-${pkgver}.tar.gz::https://github.com/datreeio/datree/archive/refs/tags/${pkgver}.tar.gz")
sha512sums=('a5b773daf7f67eba844b3f8ff4fc3d93a0e865e1cb82cce1bfe4ea0e5c8bdfafd894bbfa57249f908834fbaadc23f1a2664cf8aee8820170c1a5535156fa4aac')
b2sums=('6e66b59ec534e9593d5cb5ce65ccbcfb145f1788b1e860242ae8d8e5ce55c3b1d11ca77b156f7cdc934a1c91e16b14f40919d16e7c12d4df8e88807fee98e668')
options=('!lto')

build() {
  cd "${pkgname}-${pkgver}"
  export CGO_LDFLAGS="$LDFLAGS"
  export CGO_CFLAGS="$CFLAGS"
  export CGO_CPPFLAGS="$CPPFLAGS"
  export CGO_CXXFLAGS="$CXXFLAGS"
  export GOFLAGS='-buildmode=pie -trimpath -modcacherw -mod=readonly'
  go build -ldflags="-w -s -linkmode=external" -o datree .
}

check() {
  cd "${pkgname}-${pkgver}"
  go test ./...
}

package() {
  cd "${pkgname}-${pkgver}"
  install -Dm755 datree "${pkgdir}/usr/bin/datree"
}
